package org.ticlib.navigator
{
	import flash.events.Event;
	
	import mx.core.Container;
	import mx.events.FlexEvent;
	
	public class PageDescriptor extends NavigationEntityDescriptor
	{
		public var instance:Container;
		private var params:Object;
		private var reload:Boolean;
		
		override public function invokeInitialFunction(params:Object, reload:Boolean=false):void
		{
			if(instance.hasEventListener(FlexEvent.SHOW))
				instance.removeEventListener(FlexEvent.SHOW, onPageShow);
			instance.addEventListener(FlexEvent.SHOW, onPageShow);
			this.params = params;
			this.reload = reload;
		}
		
		private function onPageShow(e:Event):void
		{
			if((instance) && (initialFunction != null))
				instance[initialFunction](params, reload);
		}
	}
}